#version 460
#extension GL_GOOGLE_include_directive : enable

#include "../../../../core/shader_tranform.h"
#include "../../../../core/shader_widget_panel.h"
#include "../panel.h"
//#include "lib/project_matrix.glsl"

layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inWeights;
layout(location = 2) in vec2 inNormal;

layout(location = 0) out vec2 gCoords;
layout(location = 1) out flat uint gInstanceIndex;


//layout(std430, column_major, binding = DEF_BINDING_WIDGET_TextureID) readonly buffer U5_Matrix {
//	uint m_TextureArrayID[];
//};


 
void main(void) {
	gInstanceIndex = gl_InstanceIndex;
	//gInstanceIndex = m_TextureArrayID[gl_InstanceIndex];


	mat3x2 mat = m_LP_SD[gl_InstanceIndex];

	vec4 v = f_panel_build(m_Loc, m_Scale, mat, false, inPos, inWeights, gCoords);
	//vec4 v = vec4(0.0, 0.0, 0.0, 1.0);
	//mat2 rot;
	//rot[0] = vec2(cos(mat[2].y), -sin(mat[2].y));
	//rot[1] = vec2(sin(mat[2].y), cos(mat[2].y));
	////vec2 vert = rot * inPos;
	//vec2 Invert = sign(mat[1]);
	//float radius = min(min(abs(mat[1].x), abs(mat[1].y)),  mat[2].x);
	////缩放部分大小
	//vec2 scale_size = max(abs(mat[1]) - radius, 0);
	//v.xy = (inPos * radius * Invert) + ((scale_size * Invert) * inWeights.xy * rot);
	//
	//gCoords = v.xy / (mat[1]+1);
	//v.xy += mat[0];
	//v.xy *= m_Scale;
	//v.xy += m_Loc;

	//v.xy = round(v.xy) + 0.5;
	gl_Position = mat_ProjecView * v;
	gl_PointSize = 4.0;
	
}



